#include<bits/stdc++.h>
#define ONLINE_JUDGE
#define ll long long
#define ull unsigned long long
using namespace std;

const ll N = 35, INF = 0x3f3f3f3f;

ll l, r;
ll num[N], tt;
ll dp[N][N][N][2][2];

ll dfs(ll pos, ll cnt0, ll cnt1, ll lead, ll free)
{
    if (pos == 0) return cnt0 >= cnt1 && !lead;
    if (dp[pos][cnt0][cnt1][lead][free] != -1) return dp[pos][cnt0][cnt1][lead][free];
    ll ans = 0;
    ll up = free ? 1 : num[pos];
    for (ll i = 0;i <= up;i++) {
        if (lead && i == 0) ans += dfs(pos - 1, cnt0 - 1, cnt1, 1, free || i < up);
        else if (i == 0) ans += dfs(pos - 1, cnt0, cnt1, 0, free || i < up);
        else if (i == 1) ans += dfs(pos - 1, cnt0 - 1, cnt1 + 1, 0, free || i < up);
    }
    dp[pos][cnt0][cnt1][lead][free] = ans;
    return ans;
}

ll f(ll x)
{
    tt = 0;
    while (x) {
        num[++tt] = x % 2;
        x /= 2;
    }
    memset(dp, -1, sizeof dp);
    return dfs(tt, tt, 0, 1, 0);
}

void solve()
{
    cin >> l >> r;
    cout << f(r) - f(l - 1);
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll T = 1;
    //cin>>T;
    for (ll i = 1;i <= T;i++) {
        solve();
    }
}